package com.stepforward.me;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

public class HelloTabWidget extends TabActivity {
	TabHost tabHost;
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.tabmain);
	    Resources res = getResources(); // Resource object to get Drawables
	    tabHost = (TabHost)findViewById(android.R.id.tabhost);
	   // TabHost tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, DatePicker.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Direction").setIndicator("Direction",
	                      res.getDrawable(R.drawable.ic_menu_tag))
	                  .setContent(intent);
	    tabHost.addTab(spec);

	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, BusTracker.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Real Time").setIndicator("Real Time",
	                      res.getDrawable(R.drawable.ic_menu_clock))
	                  .setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, QuickBus.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Quick Bus").setIndicator("Quick Bus",
	                      res.getDrawable(R.drawable.ic_menu_light))
	                  .setContent(intent);
	   
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, FavoriteRoute.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Favorite Route").setIndicator("Favorite Route",
	                      res.getDrawable(R.drawable.ic_menu_love))
	                  .setContent(intent);
	   
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, CurrentLocationWithMap.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("Current Location").setIndicator("Current Location",
	                      res.getDrawable(R.drawable.ic_menu_flag))
	                  .setContent(intent);
	   
	    tabHost.addTab(spec);
	    
	    // Create an Intent to launch an Activity for the tab (to be reused)

	    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
            public void onTabChanged(String tabId) {
            	setTabColor(tabHost);
        }
});
	    tabHost.setCurrentTab(0);
	}
	public void setTabColor(TabHost tabhost) {
		
	    for(int i=0;i<tabhost.getTabWidget().getChildCount();i++)
	    {
	       tabhost.getTabWidget().getChildAt(i).setBackgroundColor(Color.GRAY); //unselected
	    }
	   
	    tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab()).setBackgroundColor(Color.parseColor("#ADE455")); // selected
	}
}